/**
 * a special space ship 
 * this spacel space ship runs after the human ships(human and crazy human) and if  it
 * gets the distance between the human ship to the special ship is 0.2 or less the special ship
 * drains the energy of the human ship to 0
 * @author sivandaniel 
 *
 */
public class Special extends ComputerControlled {

	
	private static final int DRAIN_ENERGY = -100;


	public Special(){
		super();
	}
	
	 public void collidedWithAnotherShip() {
		this.teleport(); 
	 }
	

	@Override
	public void doAction(SpaceWars game) {
		SpaceShip nearShip=game.getClosestShipTo(this);

		//the shield is off in default every round
		this.turnShieldOff();
		
		//checks if near sheep is human ship
		if(nearShip instanceof Human){
			
			//runs after the ship
			this.goAfterSpaceShip(game);
			
			//if the closest human ship distance is less then 0.2 it has no energy
			if(nearShip.getPhysics().distanceFrom(this.getPhysics())<=CLOSEST_SHIP_CONDITION){
				
				//drains the ship energy
				nearShip.setEnergy(DRAIN_ENERGY);
				
				this.goAfterSpaceShip(game);
				
			}
		}
		else
			//if the closest ship is not human run from her 
			this.runFromSpaceShip(game);
		
		//the ship is regaining energy every round
		this.setEnergy(INITIAL_ENERGY-this.energy);
	
	}
	
		
	
}
